package com.home.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.home.demo.dao.ChatHistoryDao;
import com.home.demo.entity.ChatHistoryEntity;
import com.home.demo.entity.vo.chatHistory.ChatHistoryAndUserInfoVO;
import com.home.demo.service.ChatHistoryService;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("chatHistoryService")
public class ChatHistoryServiceImpl extends ServiceImpl<ChatHistoryDao, ChatHistoryEntity> implements ChatHistoryService {

    /**
     * 点击用户进入聊天框显示信息
     * @return
     */
    @Override
    public List<ChatHistoryEntity> getList(String uid,String pid) {
        List<ChatHistoryEntity> list = this.list(new QueryWrapper<ChatHistoryEntity>()
                .eq("send_id", uid)
                .eq("receive_id", pid)
                .or()
                .eq("send_id", pid)
                .eq("receive_id", uid)
                .orderByAsc("create_time"));

        return list;
    }

    @Override
    public List<ChatHistoryAndUserInfoVO> getSocketList() {
        return baseMapper.getSocketList();
    }
}